$(function(){
	$("#searchBook").bind('input propertychange', function(){
		findBookInfoAjax.send();
	});
});
var BookPage = {
	'uploadBook' : function(){
		MsgBox.open("blogAdd", "上传书籍", ctx + "/book/bookAddIndex", '570px');
	},
	'showBookDetail' : function(index, item) {
		debugger;
		var imageFile = ctx + "/datum/file/fileDownload?fileId="
				+ item.coverFileId;
		var pdfFile = ctx
				+ "/"
				+ resourceVersion
				+ "/res/libs/pdfjs/generic/web/viewer.html?file="
				+ encodeURIComponent(ctx + "/datum/file/fileDownload?fileId="
						+ item.urlFileId);
		$(".pfdRead").attr("href", pdfFile);
		$("#bookImageShow").attr("src", imageFile);
		$("#bookName").text(item.bookName);
		$("#comments").text(item.comments);
		$("#progress").text(item.progress);
		var blogListVo = item.blogInfoVOList;
		var html = "";
		var url = "";
		for (var i = 0; i < blogListVo.length; i++) {
			var obj = blogListVo[i];
			var fileName = obj.fileInfo.fileName;
			if (fileName.startsWith("http://") || fileName.startsWith("https://")
					|| fileName.startsWith("ftp://")) {
				url = fileName;
			} else {
				url = blogPath + "/datum/" + fileName;
			}
			html += "<p><a style='color:blue' target='_Blank' href='" + url + "'>" + obj.blogName + "</a></p>"
		}
		$("#caption").empty();
		$("#caption").append(html);
	},
    'deleteBook' : function(item, e, rowNumber){
    	bookDeleteAjax.tempUrl(function(url){
			return url + "/" + item.bookId;
		});
    	bookDeleteAjax.send();
    },
    'onBookDeleteSucc' : function(data, status, xhr){
    	$.messager.info(data.message);
		var mWindow = MsgBox.getCurrentOpenDialogWindow();
		mWindow.bookInfoDatatable.refresh();
    },
    'updateBook' : function(item){
    	MsgBox.open("updateBook", "更新书籍信息", ctx + "/book/update/index/" + item.bookId, '300px');
    },
    'saveUpdateBook' : function(){
    	saveUpdateAjax.send();
    },
    'onUpdateSucc' : function(){
    	var mWindow = MsgBox.getCurrentOpenDialogWindow();
		mWindow.bookInfoDatatable.refresh(false);
		MsgBox.closeActiveDialog();
    } 
};
